﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace AdvancedControlCollection {
    // Learn more about making custom code visible in the Xamarin.Forms previewer
    // by visiting https://aka.ms/xamarinforms-previewer
    [DesignTimeVisible(false)]
    public partial class MainPage : ContentPage {
        public MainPage() {
            InitializeComponent();

            SizeChanged += (sender, args) =>
                VisualStateManager.GoToState(BoxStackLayout,
                    Width > 600 ? "Landscape" : "Portrait");

            PoetryListView.ItemsSource = new List<Poetry> {
                new Poetry {Name = "Name 1", Content = "Content 1"},
                new Poetry {Name = "Name 2", Content = "Content 2"},
                new Poetry {Name = "Name 3", Content = "Content 3"}
            };
        }

        private void PoetryListView_OnItemTapped(object sender,
            ItemTappedEventArgs e) {
            DisplayAlert("Item Tapped!",
                "You tapped " + (e.Item as Poetry)?.Name, "OK");
        }
    }

    public class Poetry {
        public string Name { get; set; }
        public string Content { get; set; }
    }
}